import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig((command, mode) => {
  const publicDir = resolve('resources')
  const envDir = resolve('build')
  return {
    main: {
      plugins: [externalizeDepsPlugin()]
    },
    preload: {
      plugins: [externalizeDepsPlugin()]
    },
    renderer: {
      publicDir,
      envDir,
      envPrefix: 'RENDERER_',
      resolve: {
        extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
        alias: {
          '@renderer': resolve('src/renderer/src'),
          '@module': resolve('node_modules'),
          '@package.json': resolve('package.json')
        }
      },
      plugins: [vue()]
    }
  }
})
